/**
 * 
 */
package org.sishoras.logic;

import java.util.List;

import org.sishoras.dao.DAOFactory;
import org.sishoras.interceptors.DAOInterceptor;
import org.sishoras.modelo.Aula;
import org.vraptor.annotations.Component;
import org.vraptor.annotations.InterceptedBy;

/**
 * This class is part of the SisHoras project	
 * Creation:  30/12/2008 20:33:02
 * TODO
 * 
 * @author Walker Rabelo
 * 
 */
@Component
@InterceptedBy(DAOInterceptor.class)
public class AulaLogic {

	private final DAOFactory daoFactory;
	
	private Aula aula;	
	private List<Aula> aulas;
	
	public AulaLogic(DAOFactory factory) {
		// TODO Auto-generated constructor stub
		this.daoFactory = factory;
	}
	public void form(){
		
	}	
	public void editar(Aula aula){
		this.aula = this.daoFactory.getAulaDao().carregar(aula.getId());
	}	
	public void armazena(Aula aula){
		this.daoFactory.beginTransaction();
		this.daoFactory.getAulaDao().atualiza(aula);
		this.daoFactory.commit();
	}
	public void remove(Aula aula){
		this.daoFactory.beginTransaction();
		this.daoFactory.getAulaDao().remover(aula);
		this.daoFactory.commit();
	}
	public void lista(){
		aulas = this.daoFactory.getAulaDao().getLista();
	}

	/**
	 * @return the aulas
	 */
	public List<Aula> getAulas() {
		return aulas;
	}

	public Aula getAula() {
		return aula;
	}
}
